#!/usr/bin/python
# coding=utf-8

import plotly.plotly
from plotly.graph_objs import *
import plotly.graph_objs as go
import plotly.tools as tool


#等高线类,后面是立体图

z = [
    [1000,1000,1000,1000,1000,1000,1000],
    [1444,1529,1581,1575,1571,1572,1579],
    # [2000,2000,2000,2000,2000,2000,2000],
    [2014,2109,2132,2150,2129,2118,2115],
    [2612,2644,2589,2569,2609,2637,2606],
    # [3000,3000,3000,3000,3000,3000,3000],
    [3061,3036,3075,3082,3061,3075,3044],
    # [4000,4000,4000,4000,4000,4000,4000]
]
'''
with open("/Users/Vicky/Documents/workspace/fission/long/intervene.log") as apidata:
    for i in apidata:
        data = i.split("\n")[0].split(",")
        z.append(data)

#这是单独一个表格的情况,但没找到去掉等高线的方法
data = Data([
    Contour(
        z=z,
        # contours = dict(
        #     coloring="heatmap"
        # )
    )
])
plotly.offline.plot(data,filename="3333.html")
'''

data = {
    'z': z,
    'connectgaps': True,
    'type': 'heatmap',
    'zsmooth': 'best',
    'showscale': True
}
fig = tool.make_subplots(rows=1, cols=1)
fig.append_trace(data, 1, 1)
plotly.offline.plot(fig,filename= "3333.html")
'''
# matrix = [[float(zij)+10 for zij in zi] for zi in z]
matrix = [[20 for zij in zi] for zi in z]#为了让立体图压扁
plotly.offline.plot([
     dict(
            z=z,
            type="surface"
    ),
    dict(
            z=matrix,
            showscale=False,
            opacity=0.01,#透明度
            type="surface"
    )
], filename="2222.html")
'''
#立体图只能是正方体
data = [
    go.Surface(
        z=z
    )
]
layout = go.Layout(
    title='Mt Bruno Elevation',
    autosize=False,
    width=500,
    height=500,
    margin=dict(
        l=65,
        r=50,
        b=65,
        t=90
    )
)
fig = go.Figure(data=data,layout=layout)
plotly.offline.plot(fig,filename="2222.html")